#define _CRT_SECURE_NO_WARNINGS 1
#include <vector>
#include <iostream>
using namespace std;
class Solution {
public:
    int wiggleMaxLength(vector<int>& nums)
    {
        int n = nums.size();
        vector<int> f(n, 1);
        vector<int> g(n, 1);
        int Max = 1;
        for (int i = 1;i < n;i++)
        {
            for (int j = i - 1;j >= 0;j--)
            {
                if (nums[i] > nums[j])
                {
                    f[i] = max(g[j] + 1, f[i]);
                }
                else if (nums[i] < nums[j])
                {
                    g[i] = max(f[j] + 1, g[i]);
                }
            }
            Max = max(Max, max(f[i], g[i]));
        }
        for (auto& a : f) cout << a << " ";
        cout << endl;
        for (auto& a : g) cout << a << " ";
        cout << endl;
        return Max;
    }
};